home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / rlib / num2str < prev    next >
Text File  |  1994-05-08  |  681b  |  33 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. //  Synopsis:    Convert a number object into a string-object.
  4.  
  5. //  Syntax:    num2str ( N )
  6.  
  7. //  Description:
  8.  
  9. //  Num2str converts the real-numeric argument into a string, which
  10. //  is the return value. 
  11. //-------------------------------------------------------------------//
  12.  
  13. num2str = function ( N )
  14. {
  15.   local (i, j, s, stmp)
  16.  
  17.   if (class (N) == "num" && type (N) == "real")
  18.   {
  19.     s = [];
  20.     for (i in 1:N.nr)
  21.     {
  22.       for (j in 1:N.nc)
  23.       {
  24.         sprintf (stmp, "%.4g", N[i;j]);
  25.         s[i;j] = stmp;
  26.       }
  27.     }
  28.     return s;
  29.   else
  30.     error ("num2str: argument must be numeric-real");
  31.   }
  32. };
  33.